<?php
/**
 * 平衡二叉树结点
 */

namespace Xxb\XxbPhpAlgo;

class BalanceBinaryTreeNode
{
    /**
     * 左孩子结点
     * @var self|null
     */
    private $left;

    /**
     * 右孩子结点
     * @var self|null
     */
    private $right;

    private $value;

    /**
     * 结点的高度
     * @var int
     */
    private $height;

    /**
     * @return BalanceBinaryTreeNode|null
     */
    public function getLeft()
    {
        return $this->left;
    }

    /**
     * @param BalanceBinaryTreeNode|null $left
     */
    public function setLeft($left)
    {
        $this->left = $left;
    }

    /**
     * @return BalanceBinaryTreeNode|null
     */
    public function getRight()
    {
        return $this->right;
    }

    /**
     * @param BalanceBinaryTreeNode|null $right
     */
    public function setRight($right)
    {
        $this->right = $right;
    }

    /**
     * @return mixed
     */
    public function getValue()
    {
        return $this->value;
    }

    /**
     * @param mixed $value
     */
    public function setValue($value)
    {
        $this->value = $value;
    }

    /**
     * @return int
     */
    public function getHeight()
    {
        return $this->height;
    }

    /**
     * @param int $height
     */
    public function setHeight($height)
    {
        $this->height = $height;
    }

    public function __construct($value)
    {
        $this->value = $value;
        $this->left = $this->right = null;
        $this->height = 1;
    }
}
